package com.sybkl.bigdatastudentmybatisplus.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * swagger3整合 knife4j 优化体验
 * 访问方式：
 * http://{ip}:{port}/doc.html，访问方式和之前的保持一致，如果项目中配置拦截器等，需要放开doc.html静态资源
 * http://localhost:10029/doc.html
 */

@Configuration
public class SwaggerConfig {
    @Bean
    public Docket desertsApi() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.sybkl.bigdatastudentmybatisplus.controller"))        //配置扫描路径
                .paths(PathSelectors.any())
                .build()
                .groupName("myGroup")
                .enable(true); // 配置是否开启swagger
    }

    // api基本信息
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Swagger3接口文档")
                .description("继续看风景去，世间万千景致有大美，等我千万年，不可辜负。")
                .contact(new Contact("山渐青", "http://mail.qq.com", "sybkl@qq.com"))        //作者信息
                .version("1.0")
                .build();
    }
}
